<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>   
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags"%> 

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--
/*
*
* Copyright (c) 2011 Vaulting Systems International
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy 
* of this software and associated documentation files (the "Software"), to deal 
* in the Software without restriction, including without limitation the rights 
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 
* of the Software, and to permit persons to whom the Software is furnished to do  
* so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all  
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE  
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title><s:text name="admin.title" /></title>
	<sj:head jqueryui="true" jquerytheme="smoothness"  />
	
	<script type="text/javascript">  
	<!--
		$(document).ready(function() {
			var app = $("#application").val();
			if(app != null && app != ""){
				$("#submitRegisterApplication").attr('disabled', true);
			}
		});

	    $.subscribe('completeConfigureAws', function(event,data) {          
			//alert('completeConfigureAws');
			$('#submitConfigureAws', this).attr('disabled', 'true');
		});     

	    $.subscribe('completeRegisterApplication', function(event,data) {          
			//alert('completeConfigureAws');
			$('#submitRegisterApplication', this).attr('disabled', 'true');
		});     

	    $.subscribe('completeSaveNewPrivateKey', function(event,data) {          
			//alert('completeConfigureAws');
			$('#submitSaveNewPrivateKey', this).attr('disabled', 'true');
		});     
	
	-->		
	</script>	
	<style>
	
	a.normalLink:link { color: #0000FF; font-size:14px; font-style:normal;
		font-weight:bold; text-decoration: underline }
	a.normalLink:visited { color: #0000FF; font-size:14px; font-style:normal;
		font-weight:bold; text-decoration: underline }
	a.normalLink:hover { color: #FF0000; font-size:14px; font-style:normal;
		font-weight:bold; text-decoration: underline }
		
	#adminTabs {font-size:12px;font-weight:bold;}		
	</style>
	
</head>
<body bgColor="#ffffff" leftMargin="0" topMargin="0" rightMargin="0">

	<div id="headline">
	<h1 class="ui-state-default" style="background: none; border: none;"><s:text name="headline.title" /></h1>
	<h4 class="ui-state-default" style="background: none; border: none;"><s:text name="headline.version" /></h4>
	</div>

	<sj:tabbedpanel id="adminTabs" animate="true" collapsible="true" useSelectedTabCookie="true">       
	   <sj:tab id="tab1" target="tone" label="Configure AWS"/> 
	   <sj:tab id="tab2" target="ttwo" label="Register Application"/>       
 	   <sj:tab id="tab3" target="tthree" label="New Private Key"/>     
 
    	<div id="tone"> 
    	
			<h3 class="ui-state-default" ><s:text name="admin.configure.aws.title" /></h3>
	
			<s:form id="configureAwsForm" name="configureAwsForm" action="configureAws.action" method="post" validate="true">
			
		    <s:textfield name="accessKeyId" value="%{accessKeyId}" 
		    	cssClass="ui-state-default" cssStyle="background: none;" maxlength="255"
		    	label="%{getText('admin.aws.access.key.label')}" size="60" required="true" />
		    	
		    <s:textfield name="secretAccessKey" value="%{secretAccessKey}"
		    	cssClass="ui-state-default" cssStyle="background: none;" maxlength="255"
		    	label="%{getText('admin.aws.secret.access.key.label')}" size="60" required="true"/>
	
			<sj:submit 
				name="submitConfigureAws"
				id="submitConfigureAws"
				targets="divResultConfigureAws" 
				onCompleteTopics="completeConfigureAws"
				effect="highlight" 
				value="Submit" 
				button="true"
			/>
			</s:form>
			<br /><s:text name="required.fields.label" />
			<br /><br />
			<div id="divResultConfigureAws" class="ui-state-default" style="background: none; border: none;"></div>
    	
    	
	 	</div>   
    
   		<div id="ttwo"> 

			<h3 class="ui-state-default" ><s:text name="admin.register.application.title" /></h3>
	
			<s:form id="registerApplicationForm" name="registerApplicationForm" action="registerApplication.action" method="post" validate="true">
			
		    <s:textfield name="vendorApiKey" value="%{vendorApiKey}" 
		    	cssClass="ui-state-default" cssStyle="background: none;" maxlength="255"
		    	label="%{getText('admin.vendor.api.key')}" size="60" required="true" />
		    	
		    <s:textfield name="applicationName" value="%{applicationName}"
		    	cssClass="ui-state-default" cssStyle="background: none;" maxlength="255"
		    	label="%{getText('admin.application.name')}" size="40" required="true"/>
		    	
		    <s:textfield name="deviceId" value="%{deviceId}" 
		    	cssClass="ui-state-default" cssStyle="background: none;" maxlength="255"
		    	label="%{getText('admin.device.id')}" size="40" />
		
			<sj:submit 
				name="submitRegisterApplication"
				id="submitRegisterApplication"
				targets="divResultRegisterApplication"
				onCompleteTopics="completeRegisterApplication" 
				effect="highlight" 
				value="Submit" 
				button="true"
			/>
			</s:form>
			<br /><s:text name="required.fields.label" />
			<br /><br />
			<div id="divResultRegisterApplication" class="ui-state-default" style="background: none; border: none;"></div>

		</div> 
	 	    
    	<div id="tthree"> 

			<h3 class="ui-state-default" ><s:text name="admin.new.private.key.title" /></h3>
	
			<s:form id="saveNewPrivateKeyForm" name="saveNewPrivateKeyForm" action="saveNewPrivateKey.action" method="post" validate="true">
			
		    <s:textfield name="privateKey" value="%{privateKey}" 
		    	cssClass="ui-state-default" cssStyle="background: none;" maxlength="255"
		    	label="%{getText('admin.new.private.key.label')}" size="60" required="true" />

			<sj:submit 
				name="submitSaveNewPrivateKey"
				id="submitSaveNewPrivateKey"
				targets="divResultSaveNewPrivateKey" 
				onCompleteTopics="completeSaveNewPrivateKey"
				effect="highlight" 
				value="Submit" 
				button="true"
			/>
			</s:form>
			<br /><s:text name="required.fields.label" />
			<br /><br />
			<div id="divResultSaveNewPrivateKey" class="ui-state-default" style="background: none; border: none;"></div>
 		</div>      
    
    </sj:tabbedpanel> 
    <br /><br />
    <div>
       <a class="normalLink" href='<s:url action="home"/>'><s:text name="admin.dashboard.return.label" /></a>
    </div>
    <br /><br />
    <div align="center" class="ui-state-default">
      <s:text name="footer.copy" /><br/>
      <a class="normalLink" href='<s:url value="/j_spring_security_logout"/>'><s:text name="logout.label" /></a>
    </div>

</body>

</html>